<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>系统登录 - DR钻戒后台管理系统</title>
    <link rel="stylesheet" href="css/style.css"/>
    <script src="../js/jquery-1.12.4.js"></script>
</head>

<body class="login_bg">
    <section class="loginBox">
        <header class="loginHeader">
            <h1>DR钻戒后台管理系统</h1>
        </header>
        <section class="loginCont">
            <form class="loginForm" >
                <div class="inputbox">
                    <label for="user">用户名：</label>
                    <input id="user" type="text" name="user"/>
                </div>
                <div class="inputbox">
                    <label for="mima">密码：</label>
                    <input id="mima" type="password" name="mima"/>
                </div>
                <div class="subBtn">
                    <input type="button" id="login-button" value="登录" />
                    <input type="reset" value="重置"/>
                </div>
            </form>
        </section>
    </section>
</body>
<script type="text/javascript">
    $(document).ready(function() {
        $("#login-button").click(function () {
            var user = $("#user").val();
            var mima = $("#mima").val();

            if ($('#user').val() == ''||$('#user').val() == null) {
                alert("请输入用户名!")
                return false;
            }

            if ($('#mima').val() == ''||$('#mima').val() == null) {
                alert("请输入密码!")
                return false;
            }
            $.post("http://localhost:8080/DiamondRing/back-Login-Servlet","user="+user+"&mima="+mima,function(data){
                if (data>0){
                    alert("登录成功!")
                    location.href = "http://localhost:8080/DiamondRing/back-stage-Management/index.html";
                }else{
                    alert("密码或用户名错误,请重新登录!")
                }
            });
        })
    })
    $(document).keyup(function(event){
        if(event.keyCode ==13){
            $('#login-button').click();
        }
    });
</script>
</html>